import { View, Text } from '@tarojs/components'
import './Organ.less'
import Taro,{ useReady } from '@tarojs/taro'
import http from '../../store/http'
import {useState } from 'react'

function Organ(){

    const toproject=()=>{
        Taro.switchTab({
            url: '/pages/project/Project'
          })
    }

    const [data,setData]=useState([]);
    const [list,setList]=useState([]);

    useReady(()=>{
        console.log(Taro.getCurrentInstance().router.params.org_id)
        
        http({
            url:'/findByIdOrganization',
            data:{
                org_id:Taro.getCurrentInstance().router.params.org_id
            },
            header:{
                'content-type':'application/json'
            }
        }).then((res)=>{
            console.log(res);
            setData(res);
            if(res.length){
                http({
                    url:'/findAllSetmeal',
                    header:{
                        'content-type':'application/json'
                    }
                }).then((res)=>{
                    console.log(res)
                    setList(res);
                })
            }
        })

        
    })

    return (
        <View>
            {data && data.map((v,i)=>(<View> 
                <View className="headerv">
                    <View>
                        <image className="img1" src={v.org_image} />
                    </View>
                    <View className="context">
                        <Text className="text1">{v.org_name}</Text>
                        <Text>{v.org_people} 人预约</Text>
                    </View>
                </View>
                
                    <View className="listtime">
                        <View className="greybox"></View>
                        <Text className="listcon">营业时间：周一至周六 7:30 - 10:30</Text>
                    </View>
                    <View className="listtime">
                        <View className="greybox"></View>
                        <Text className="listcon">{v.org_tel}</Text>
                    </View>
                    <View className="listtime">
                        <View className="greybox"></View>
                        <Text className="listcon">{v.org_address}</Text>
                    </View>
                </View>))}
            {/* <View> 
                <View className="headerv">
                    <View>
                        <image className="img1" src="../../public/img/xx.png" />
                    </View>
                    <View className="context">
                        <Text className="text1">南方医科大学附属第三医院</Text>
                        <Text>120 人预约</Text>
                    </View>
                </View>
                
                    <View className="listtime">
                        <View className="greybox"></View>
                        <Text className="listcon">营业时间：周一至周六 7:30 - 10:30</Text>
                    </View>
                    <View className="listtime">
                        <View className="greybox"></View>
                        <Text className="listcon">020-83761254</Text>
                    </View>
                    <View className="listtime">
                        <View className="greybox"></View>
                        <Text className="listcon">广州市天河区中山大道西183号新门诊3楼体检中心</Text>
                    </View>
                </View> */}

                <View className="midline"></View>

                <View className="totalbox">
                    {list && list.map((v,i)=>(<View onClick={toproject} className="photobox">
                        <image className="img2" src={v.com_image} />
                        <View className="sale">sale</View>
                        <Text>{v.com_proName}</Text>
                        <Text>{v.com_address}</Text>
                        <View>
                            <Text>￥{v.com_salesPrice}</Text>
                            <Text className="text2">￥{v.com_costPrice}</Text>
                        </View>
                    </View>))}
                    {/* <View onClick={toproject} className="photobox">
                        <image className="img2" src="../../public/img/xx.png"/>
                        <View className="sale">sale</View>
                        <Text>老年人体检套餐（女）</Text>
                        <Text>老年人医科大学附属第三医院</Text>
                        <View>
                            <Text>￥998</Text>
                            <Text className="text2">￥1200</Text>
                        </View>
                    </View> */}
                    {/* <View onClick={toproject} className="photobox">
                    <image className="img2" src="../../public/img/xx.png"/>
                        <View className="sale">sale</View>
                        <Text>老年人体检套餐（女）</Text>
                        <Text>老年人医科大学附属第三医院</Text>
                        <View>
                            <Text>￥998</Text>
                            <Text className="text2">￥1200</Text>
                        </View>
                    </View> */}
                </View>
            </View>
    )
}
export default Organ;